﻿using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace DKPScoreWebApi.Models
{
    /// <summary>
    /// 积分项目实体类
    /// 定义可以获取积分的各种行为或成就
    /// </summary>
    public class PointItem
    {
        /// <summary>
        /// 项目ID，主键，自增
        /// </summary>
        [Key]
        public int Id { get; set; }

        /// <summary>
        /// 所属工会ID，外键关联Guild
        /// </summary>
        [Required]
        public int GuildId { get; set; }

        /// <summary>
        /// 项目名称，必填字段
        /// </summary>
        [Required]
        [MaxLength(100)]
        public string Name { get; set; }

        /// <summary>
        /// 项目详细描述
        /// </summary>
        public string Description { get; set; }

        /// <summary>
        /// 积分类型：add(加分项)、subtract(减分项)、progress(进度项)
        /// </summary>
        [Required]
        [MaxLength(20)]
        public string PointType { get; set; } // "add", "subtract", "progress"

        /// <summary>
        /// 基础积分值，加分项为正数，减分项为负数
        /// </summary>
        public int BasePoints { get; set; }

        /// <summary>
        /// 目标进度值，仅progress类型使用
        /// </summary>
        public int TargetProgress { get; set; }

        /// <summary>
        /// 项目状态，true表示启用，false表示停用
        /// </summary>
        public bool IsActive { get; set; } = true;

        /// <summary>
        /// 项目创建时间
        /// </summary>
        public DateTime CreatedAt { get; set; } = DateTime.Now;

        // 导航属性
        /// <summary>
        /// 所属工会信息
        /// </summary>
        [ForeignKey("GuildId")]
        public virtual Guild Guild { get; set; }

        /// <summary>
        /// 相关的积分记录列表
        /// </summary>
        public virtual ICollection<PointRecord> PointRecords { get; set; }
    }
}
